package main

import (
	"fmt"
)

func twoSum(nums []int, target int) []int {
	//arr := []int{0, 0}
	//for i := 0; i < len(nums); i++ {
	//	for j := i + 1; j < len(nums); j++ {
	//		if nums[i]+nums[j] == target {
	//			arr[0] = i
	//			arr[1] = j
	//		}
	//	}
	//}
	//return arr
	var mapNum = make(map[int]int)
	for k1, v1 := range nums {
		mapNum[v1] = k1
	}
	for k2, v2 := range nums {
		if mapNum[target-v2] != 0 && mapNum[target-v2] != k2 {
			return []int{mapNum[target-v2], k2}
		}
	}
	return []int{0, 0}

}
func main() {
	nums := []int{1, 3, 4, 2}
	target := 6
	fmt.Println(twoSum(nums, target))

}
